package dao

import (
	"context"
	"github.com/go-redis/redis"
	"time"
)

//声明一个全局的rdb变量
var Rdb *redis.Client

//初始化连接
func InitRedisClient() (err error) {
	Rdb = redis.NewClient(&redis.Options{
		Addr:     "180.184.70.56:6379",
		Password: "",
		DB:       0,   //数据库序号
		PoolSize: 100, //连接池大小
	})
	_, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()
	_, err = Rdb.Ping().Result()
	return err
}
